//
//  DDUserAccountViewModel.swift
//  swift微博
//
//  Created by whitcast on 16/7/13.
//  Copyright © 2016年 whitcast. All rights reserved.
//

import UIKit
//判断apptoken是否过期,判断登录状态
class DDUserAccountViewModel: NSObject {
    //判断是够登录
    var isLogin : Bool?{
        
      return whetherLogin()
    }
    //单例对象
   static var sharedUserAccountVM :DDUserAccountViewModel = DDUserAccountViewModel()
    
    //通过判断appToken是否有值来判断是否登录
    func whetherLogin()->Bool {
        //从沙河中取出数据
        let model = DDUserAccountModel.getDataFormLocal()
        guard let _ = model?.access_token else {
         
            return false
        }
        let result = model?.expressedTimeOut?.compare(NSDate())
        //降序,表明时间没到期
        if result == NSComparisonResult.OrderedDescending {
          return  true
            
        } else{
            
            return  false
        }
        
    }
    

}
